-
Notifications
You must be signed in to change notification settings - Fork 19.9k
fix(huggingface): (WIP) add Pydantic structured output support (Issue #32197) #33141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
fix(huggingface): (WIP) add Pydantic structured output support (Issue #32197) #33141
Conversation
|
The latest updates on your projects. Learn more about Vercel for GitHub. |
CodSpeed Instrumentation Performance ReportMerging #33141 will create unknown performance changesComparing Summary
Footnotes
|
ccurme
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hi @rahulmansharamani14, the plan sounds good to me although it doesn't look implemented here (I see no logical change as we continue to instantiate JsonOutputParser in each case). Let me know if you have any specific questions.
|
Hi @ccurme @mdrxy, I've made the change and added 3 unit tests to verify the fix:
All tests pass locally. I kept the scope minimal to get feedback before adding more coverage (backward compatibility, include_raw, integration tests, etc.) Thanks in advance :) |
This draft PR begins addressing #32197 (Support structured output with Pydantic models in langchain-huggingface).
Currently,
ChatHuggingFace.with_structured_outputconverts Pydantic schemas into JSON Schema and parses into dicts.PydanticOutputParseris not utilized, leading to dict outputs and extra token usage on retries.What’s included
is_basemodel_subclass).PydanticOutputParserwhen schema is Pydantic andmethod="json_schema".json_mode.function_callingwith Pydantic continues to raiseNotImplementedError.Next steps (planned)
libs/partners/huggingface/tests/unit_tests/for:include_raw=Truepath.xfailPydantic-related integration tests once validated.Notes
Opening early for review to validate direction before completing test coverage and unskipping integration tests.